using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using DCRF.Common.Helper;
using DCRF.Common.Primitive;
using DCRF.Common.Core;

namespace DCRF.Common.Interface
{
    /// <summary>
    /// This interface shows behavior of a framework which acts as Block broker.
    /// Loads Blocks from repository.
    /// </summary>
    public interface IBlockBroker
    {
        /// <summary>
        /// Failover broker is a helper broker so if this broker could not perform the given operation, it calls failover
        /// This is used so a BlockWeb can have multiple brokers transparently: e.g. local, remote and runtime broker
        /// </summary>
        IBlockBroker FailoverBroker
        {
            get;
            set;
        }

        List<CID> Blocks
        {
            get;
        }

        /// <summary>
        /// Loads a Block into memory
        /// </summary>
        /// <param name="handle"></param>
        /// <returns></returns>
        IContainedBlock LoadBlock(CID handle, params object[] args);

        /// <summary>
        /// Called when we want to release resources that are associated to a Block
        /// </summary>
        /// <param name="comp"></param>
        void DisposeBlock(IBlock comp);
        
        /// <summary>
        /// Sets folder of the repository so Block broker can find folders of Blocks when 
        /// Needs to load them
        /// </summary>
        /// <param name="options"></param>
        void SetupBroker(IBlockBrokerOptions options);

        void ClearCache();
    }
}
